1. Technology Field
The present invention generally relates to a data writing method, in particular, to a data writing method for a flash memory and a controller using the same.
2. Description of Related Art
Along with the widespread of digital cameras, camera phones, and MP3 in recently years, the consumers' demand to storage media has increased drastically too. Flash memory is one of the most adaptable memories for such battery-powered portable products due to its characteristics such as data non-volatility, low power consumption, small volume, and non-mechanical structure. Besides being applied in foregoing portable products, flash memory is also broadly applied to external products such as flash cards and flash disks. Thereby, flash memory has become one of the most focused electronic products in recent years.
A flash memory is usually divided into a plurality of physical blocks, and for the convenience of description, these physical blocks will be referred as blocks thereinafter. Each bit in a block of a flash memory can only be programmed from “1” to “0”. Accordingly, an erasing operation has to be performed before writing data to a memory address which contains old data. Generally speaking, data in a flash memory is erased in unit of blocks. Namely, each block contains the smallest number of memory cells which are erased together. Each block is usually divided into a plurality of pages, and each page is the smallest programming unit, namely, each page is the smallest unit for writing or reading data. It should be noted that in some other different flash memory designs, the smallest programming unit may also be sector, namely, a page has a plurality of sectors and each sector is served as the smallest programming unit, such as in a single level cell (SLC) NAND flash memory having the number of program (NOP) as 4.
According to the conventional technique, when the programming unit is smaller than the erasing unit and a new data is to be written into a flash memory, a substitute block is first selected from the flash memory, the old valid data before an address at where the new data is to be written in the original block is written into the substitute block, and the new data is then written into the substitute block right after the old valid data.
However, moving the old data may become meaningless if a next writing command is to update the old data previously written into the substitute block, and accordingly the system performance may be reduced.